﻿<UserControl x:Class="SqLiteEditor.Templates.TStructureWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:editor="http://icsharpcode.net/sharpdevelop/avalonedit"
             xmlns:staticData="clr-namespace:SqLiteEditor.Helper"
             xmlns:avalonDock="http://avalondock.codeplex.com" >
    <Grid Name="LayoutRoot">
        <Grid.Resources>
            <staticData:DataTypeList x:Key="DataTypeList"/>
            <staticData:DataTypeBool x:Key="DataTypeBool"/>
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="50*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="50*"/>
        </Grid.RowDefinitions>
        <DataGrid x:Name="SqliteStructureDataGrid" AutoGenerateColumns="False" Grid.Row="0"  IsReadOnly="False" Width="Auto" Margin="2" Grid.RowSpan="1" ItemsSource="{Binding DataContext,ElementName= LayoutRoot,Mode=TwoWay}">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding ColumnName}" Header="ColumnName" Width="Auto"/>
                <DataGridTemplateColumn Header="DataType" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DataType}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Height="22" 
                                      ItemsSource="{StaticResource DataTypeList}"
                                      SelectedItem="{Binding DataType}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>

                </DataGridTemplateColumn>
                <!--<DataGridTextColumn Binding="{Binding AllowNull}" Header="AllowNull" Width="Auto"/>-->
                <DataGridTemplateColumn Header="AllowNull" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding AllowNull}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Height="22" 
                                      ItemsSource="{StaticResource DataTypeBool}"
                                      SelectedItem="{Binding AllowNull}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>

                </DataGridTemplateColumn>

                <DataGridTextColumn Binding="{Binding DefaultValue}" Header="DefaultValue" Width="Auto"/>
                <DataGridTextColumn Binding="{Binding PrimaryKey}" Header="PrimaryKey" Width="Auto"/>
            </DataGrid.Columns>
        </DataGrid>

        <GridSplitter Grid.Row="1" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="7" />

        <editor:TextEditor x:Name="QueryEdittor" Grid.Row="2" FontFamily="Consolas" ShowLineNumbers="True" WordWrap="True" Grid.RowSpan="2" Margin="2" />
        <Button Content="Button" HorizontalAlignment="Left" Margin="302,20,0,0" Grid.Row="2" VerticalAlignment="Top" Width="117" Click="Button_Click_1"/>

    </Grid>
</UserControl>
